home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 2
/
SPACE - Library 2 - Volume 1.iso
/
games
/
73
/
pascal
/
joysubs.s
< prev
next >
Wrap
Text File
|
1986-11-21
|
2KB
|
72 lines
.xdef INIT_STICK,END_STICK,STICK
.text
*
* Get the address of the keyboard packet handle table, and replace the joystick
* handler. Set up our own vector as the joystick handler
INIT_STICK:
bsr get_vectors
move.l 24(a0),a1 * Stick handler is at *a0[6]
move.l a1,old_vec
move.l #do_stick,24(a0)
move.w #$12,d0 * Turn mouse off
bsr send_cmd
move.w #$15,d0 * And turn joystick on, interrogate mode
bsr send_cmd
rts * Then return to caller
*
* Turn off joysticks, and turn on mouse. Replace the old joystick packet
* handler vector.
END_STICK:
move.w #$08,d0 * Turn off joysticks by turning on mouse
bsr send_cmd
bsr get_vectors * Now replace old stick handler
move.l old_vec,a1
move.l a1,24(a0)
rts * Return to caller
*
get_vectors:
move.w #34,-(sp) * Get address of keyboard packet handler tbl
trap #14
add.l #2,sp
move.l d0,a0
rts
*
send_cmd:
move.w d0,-(sp) * Just perform a bconout to the keyboard
move.w #4,-(sp)
move.w #3,-(sp)
trap #13
add.l #6,sp
rts
*
do_stick:
lea stick0,a1 * Get a pointer to our data area in a1
move.b (a0),d1 * Get direction bits
move.b d1,(a1) * and save in our data
move.b 1(a0),d1
move.b d1,1(a1)
st done
notevent:
rts
*
STICK:
move.w #$16,d0 * Interrogate joystick
clr.b done
bsr send_cmd
wait: tst.b done
beq wait
move.l (sp)+,a0 * Save return address
move.w (sp)+,d1 * get stick number (0-1)
and.w #1,d1
lea stick0,a1
move.b (a1,d1.w),d0 * Return with our stick value as the fn. result
and.w #$FF,d0
jmp (a0) * and return
*
.bss
old_vec: .ds.l 1
stick0: .ds.b 1 * position for stick 0
stick1: .ds.b 1 * and stick 1
done: .ds.b 1
.end